<template>
	
	<div style="padding-bottom: 3.33rem;">
		
		<div v-if="changeState == true" style="text-align: center;padding-top: 1rem;">您还未购买任何课程</div>
		
		<!--线上课程-->
		<div class="column" style="margin-top: 0;">
			
			<div v-for="(item,index) in lesson_list">
				<div class="column_img" >
					<img :src="item.cover_pic"/>
				</div>
				<div class="column_bottom">
					<flexbox >
				      <flexbox-item :span="8">
				      	<div class="flex-demo" style="text-align: left;padding-left: 0.5rem;">
				      	  <img class="userImg" :src="item.image"/>
					      <span class="f15" style="font-size: 0.5rem;">{{item.name}}</span>
				        </div>
				      </flexbox-item>
				      <flexbox-item>
				      	<div class="flex-demo" style="color:#910A81 ;padding-top: 19px;font-size: 0.9rem;">
				      	￥199/年
				        </div>
				      </flexbox-item>
				    </flexbox>
				    <flexbox>
				      <flexbox-item :span="8"><div style="padding-top: 5px;padding-left: 0.5rem;">
				      	{{item.title}} 
				      </div></flexbox-item>
				      <flexbox-item>
				      	<div class="flex-demo section">共{{item.total_lesson}}节</div>
				      </flexbox-item>
				    </flexbox>
				    <div style="padding-left: 0.5rem;margin-top: 0.5rem;color: #C7C7C7;font-size: 0.9rem;">
				    	<span>付款时间:{{item.pay_time}}</span>
				    </div>
				    
				</div>
			</div>
			
		</div>
		
		<!--线下课程-->
		<div class="column" style="margin-top: 0;">
			
			<div v-for="(item,index) in course">
				<div class="column_img" >
					<img :src="item.cover_pic"/>
				</div>
				<div class="column_bottom">
					<flexbox >
				      <flexbox-item :span="8">
				      	<div class="flex-demo" style="text-align: left;padding-left: 0.5rem;">
				      	  <img class="userImg" :src="item.image"/>
					      <span class="f15" style="font-size: 0.5rem;">{{item.name}}</span>
				        </div>
				      </flexbox-item>
				      <flexbox-item>
				      	<div class="flex-demo" style="color:#910A81 ;padding-top: 19px;font-size: 0.9rem;">
				      	￥199/年
				        </div>
				      </flexbox-item>
				    </flexbox>
				    <flexbox>
				      <flexbox-item :span="8"><div style="padding-top: 5px;padding-left: 0.5rem;">
				      	{{item.title}} 
				      </div></flexbox-item>
				      <flexbox-item>
				      	<div class="flex-demo section">共{{item.total_lesson}}节</div>
				      </flexbox-item>
				    </flexbox>
				    <div style="padding-left: 0.5rem;margin-top: 0.5rem;color: #C7C7C7;font-size: 0.9rem;">
				    	<span>付款时间:{{item.pay_time}}</span>
				    </div>
				    
				</div>
			</div>
			
		</div>
		
		<!--会员-->
		<div class="column" style="margin-top: 0;">
			
			<div v-for="(item,index) in level">
				<div class="column_img" >
					<img :src="item.cover_pic"/>
				</div>
				<div class="column_bottom">
					<flexbox >
				      <flexbox-item :span="8">
				      	<div class="flex-demo" style="text-align: left;padding-left: 0.5rem;">
				      	  <img class="userImg" :src="item.cover_pic"/>
					      <span class="f15" style="font-size: 0.5rem;">{{item.name}}</span>
				        </div>
				      </flexbox-item>
				      <flexbox-item>
				      	<div class="flex-demo" style="color:#910A81 ;padding-top: 19px;font-size: 0.9rem;">
				      	￥199/年
				        </div>
				      </flexbox-item>
				    </flexbox>
				    <flexbox>
				      <flexbox-item :span="8">
				      	<div style="padding-top: 5px;padding-left: 0.5rem;">
					      {{item.title}} 
					    </div>
					   </flexbox-item>
				    </flexbox>
				    
				    <div style="padding-left: 0.5rem;margin-top: 0.5rem;color: #C7C7C7;font-size: 0.9rem;">
				    	<span>付款时间:{{item.pay_time}}</span>
				    </div>
				    
				</div>
			</div>
			
		</div>
		
		<tab></tab>	
	</div>
	
</template>

<script>
	
	import { base64} from 'vux'
	
	export default {
		
		components: {         
            base64
		},
		
		data () {
	    	return {
		      
		      access_token:'',
		      lesson_list:'',
		      changeState:false,
		      course:'',
		      level:''
		       
		    }

	    },
		
		
		methods: {
			
			
			//获取详情
            getDetail(){
    	  
			    this.$store.commit('updateLoadingStatus',true);
		    	
		    	this.$http.post(this.$store.state.api + 'userdd/earn',
		    	{
		    		access_token:this.access_token
		    	})
		    	.then((response) => {
		    		
		    		console.log(response)
				
				if(response.body.code == 0) {
					
					this.lesson_list = response.body.data.lesson
					this.level = response.body.data.level
					this.course = response.body.data.course
					
					if( this.level == null && this.lesson_list == null && this.course == null ){
						
						this.changeState = true
						
					}
					
				} else {
					
				}
				
				this.$store.commit('updateLoadingStatus',false);
					
				
				}, (response) => {
	                 
	                 
				});
            
            },
			
			
			
		//获取地址栏信息
		getUrlStr(name){
	      let reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)","i");
	      if(reg.test(window.location.href)){
	        return unescape(RegExp.$2.replace(/\+/g," "))
	      }
	      return undefined
	    },	
			
			
		},
		
		mounted() {
			
			var access_token = this.getUrlStr('access_token');
           var parentId = this.getUrlStr('parent_id');
           
            if(parentId == undefined){
              parentId = 0;
           }
           
           var uid = this.getUrlStr('uid');
           
           console.log(parentId.toString().indexOf('?'));
           
           if(parentId.toString().indexOf('?') > 0){
           	 parentId = parentId.split('?')[0];
           }
           
           
           var locurl = location.href;
           locurl = base64.encode(locurl.split('?')[0]);
          
           if(access_token != undefined){
         
              localStorage.setItem("access_token",access_token); 
              localStorage.setItem("parent_id",this.getUrlStr('uid'));


           }
            if(localStorage.getItem('access_token') != null){
         
              this.$root.registerjudge();
              this.$root.getShare();
              
            }else{
            	
            	console.log(222);
        	  this.$root.gotoWechat(locurl,parentId);
            }
           
       
         
    	   this.access_token = localStorage.getItem('access_token');
			
            this.getDetail();

        }
		
		
		
	}
	
	
</script>

<style>
</style>